// 导入intance对象
import instance from '../until/request.js'
// 抽取api
const getArticle = ({ id }) => {
  return instance({
    url: '/v1_0/articles/' + id,
    method: 'get'
  })
}
// 抽取api 关注用户
const followUser = ({ target }) => {
  return instance({
    url: '/v1_0/user/followings',
    method: 'post',
    data: {
      target
    }
  })
}
// 抽取api 取关用户
const unFollowUser = ({ target }) => {
  return instance({
    url: '/v1_0/user/followings/' + target,
    method: 'delete'
  })
}
// 取消点赞
const deleteLike = id => {
  return instance({
    url: '/v1_0/article/likings/' + id,
    method: 'delete'
  })
}
// 添加点赞
const addLike = id => {
  return instance({
    url: '/v1_0/article/likings',
    method: 'post',
    data: {
      target: id
    }
  })
}
// 取消不喜欢
const reqDeleteDisLike = id => {
  return instance({
    url: '/app/v1_0/article/dislikes/' + id,
    method: 'delete'
  })
}

// 添加不喜欢
const reqAddDisLike = id => {
  return instance({
    url: '/app/v1_0/article/dislikes',
    method: 'post',
    data: {
      target: id
    }
  })
}
// 暴露出去
export {
  getArticle,
  followUser,
  unFollowUser,
  deleteLike,
  addLike,
  reqAddDisLike,
  reqDeleteDisLike
}
